package controller;

import model.*;
import view.MainFrame;

import javax.swing.*;
import java.time.LocalDate;

public class LibraryApp {
    public static void main(String[] args) {
        //初始化系统
        LibrarySystem system = initializeSystem();

        // 启动GUI初始化系统
        SwingUtilities.invokeLater(() -> {
            MainFrame frame = new MainFrame(system);
            frame.setVisible(true);
        });
    }

    private static LibrarySystem initializeSystem() {
        LibrarySystem system = new LibrarySystem();

        // 添加示例资源
        system.addResource(new Book("B001", "设计模式：可复用面向对象软件的基础",
                "Erich Gamma", "978-7-111-07575-2", 1));
        system.addResource(new Book("B002", "Java核心技术 卷I",
                "Cay S. Horstmann", "978-7-111-54742-6", 11));
        system.addResource(new Magazine("M001", "计算机科学",
                42, LocalDate.of(2023, 5, 15)));
        system.addResource(new DVD("D001", "黑客帝国",
                "Lana Wachowski", 136, 1999));
        system.addResource(new DVD("D002", "盗梦空间",
                "Christopher Nolan", 148, 2010));

        // 添加示例借阅者
        system.registerBorrower(new Borrower("U001", "张三"));
        system.registerBorrower(new Borrower("U002", "李四"));
        system.registerBorrower(new Borrower("U003", "王五"));

        // 模拟借阅记录
        system.borrowResource("U001", "B001");
        system.borrowResource("U002", "D002");

        return system;
    }
}